<html>
<head>
    <title>Page Title</title>
    <meta charset="utf8"/>
    <style>
 	body{background-color:#EBEBEB;}
	li{list-style:none;}
	
	#header {width: 100%;height: 50px;background-color: #2BB2A3;}
        #header a {display: inline-block;margin-top: 8px;}
        #header span {display: inline-block;margin-top: 8px;color: white;font-size: 20px;}
		
	#content {width:100%;margin:20px auto;border-radius:3px;padding:5px;}
	ul.tital {padding:0px;width:100%;}
	ul.tital li:first-child {text-align:center;line-height:200%;}
	ul.tital li:last-child {text-align:center;color:#333333;font-size:24px;line-height:300%;padding-left:10px;font-family:"微软雅黑";font-weight:bold;}
	ul.text {margin-top:10px;text-align:left;}
	ul.text li {font-size:16px;font-weight:bold;font-family:"微软雅黑";color:#333333;line-height:30px;}
	#list {float:right;padding-right:50px;}
	#box {width:100%;margin:20px;padding:40px;}
	#box1 {float:left;margin-left:20px;width:40%;}
	#box2 {float:right;width:40%;margin-right:20px;}	
    </style>
</head>
<?php
/*
  报名.
 */
$eventId = $contentId;
$contentId=  $infoId;
$form = $this->beginWidget('CActiveForm', array(
    "id" => "saveJoinEventForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
$url = $control->getAjaxLinkUrl('saveJoinEventContent', NULL, array(
    'contentId' => $contentId,  'eventId' => $eventId));

$updateId = $control->getAjaxContainerId();

?>
<script type="text/javascript">
// this script for collecting the form data and pass to the controller action and doing the on success validations
    function addJoinEvent<?php echo $eventId; ?>() {
        var $eventPerName = $('#BDynamicFormModel_media_perName_event_info').val();
        var $eventPhoneNumber = $('#BDynamicFormModel_media_phoneNumber_event_info').val();
        var $eventSex = $('#BDynamicFormModel_media_sex_event_info').val();
        var $eventIDNumber = $('#BDynamicFormModel_media_IDNumber_event_info').val();
        if ($eventPerName !== "") {
            if ($eventPhoneNumber !== "") {
                if ($eventSex !== "") {
                    if ($eventIDNumber !== "") {
                                    var formData = new FormData($("#saveJoinEventForm")[0]);
                                    $.ajax({
                                        url: '<?php echo $url; ?>',
                                        type: 'POST',
                                        data: formData,
                                        //datatype: 'json',
                                        // async: false,
                                        beforeSend: function() {
                                            $("#ajax-loaderdiv").show();
                                        },
                                        success: function(html) {
                                            // on success do some validation or refresh the content div to display the uploaded images 
                                            jQuery("#<?php echo $updateId; ?>").html(html);
                                        },
                                        complete: function() {
                                            $("#ajax-loaderdiv").hide();
                                        },
                                        error: function(data) {
                                            alert("There may a error on uploading. Try again later");
                                        },
                                        cache: false,
                                        contentType: false,
                                        processData: false
                                    });
                                } else
                                    alert("请输入身份证号");
                            } else
                                alert("请输入性别")
                        } else
                            alert("请输入联系方式");
                    } else
                        alert("请输入姓名");
        return false;
    }
</script>
<?php
if (!isset($model))
    $model = new BDynamicFormModel ();

$eventPerNameField = 'media_perName_event_info';
$eventPhoneNumberField = 'media_phoneNumber_event_info';
$eventSexField = 'media_sex_event_info';
$eventIDNumberField = 'media_IDNumber_event_info';
$model->addField($eventPerNameField);
$model->addField($eventPhoneNumberField);
$model->addField($eventSexField);
$model->addField($eventIDNumberField);
?>
<?php
$app = Blyn::app()->getActiveApp();
?>

<body>
    <div id="header">
  <?php
            echo $control->getAjaxLink(array(
                'name' => '<img src="' . Yii::app()->request->baseUrl . '/images/BWeEvent/back.png' . '"/>',
                'id' => 'goIndex'),
                    array(
                'viewName' => 'guanzhe_index_2',
                'htmlOptions' => array(
                    'enctype' => 'multipart/form-data'
            )));
            ?>
        <span>冠者体育</span>
    </div>
    <div id="content">
        <ul class="tital">
            <li><img src="<?php echo Yii::app()->request->baseUrl . '/images/BWeEvent/register.jpg'; ?>"></li>
            <li>冠者体育报名</li>
        </ul>    
    <table class="table table-hover">
        <colgroup>
            <col class="span2">
            <col class="span4">
            <col class="span4">
        </colgroup>
        <thead>
        </thead>
        <tbody>
            <tr>
                <td>
                    <?php echo '姓名'; ?>
                </td>
                <td>
                    <?php
                     echo CHtml::activeTextField($model, $eventPerNameField, array('placeholder' => 'PerName', 'required' => true));
        ?>
                    <!--                    &nbsp;&nbsp;&nbsp;&nbsp;<a id="CreateNewType_clink" role="button" data-toggle="modal" class="btn disabled" style="font-size: 12px;margin-top: -12px;">创建新类型</a>-->
                </td>
                <td></td>
            </tr>


            <tr>
                <td> <?php echo '性别'; ?> </td>
                <td>
                    <?php
                     echo CHtml::activeTextField($model, $eventSexField, array('placeholder' => 'sex', 'required' => true));
        ?>
                </td>
                <td></td>

            </tr> 



            <tr><td> <?php echo '身份证号'; ?> </td>
                <td>
                    <?php
        echo CHtml::activeTextField($model, $eventIDNumberField, array('placeholder' => 'ID Number', 'required' => true));
        ?>
                </td>
                <td></td>   


            </tr> 



            <tr><td> <?php echo '联系电话'; ?> </td>
                <td>
                    
                        <?php
        echo CHtml::activeTextField($model, $eventPhoneNumberField, array('placeholder' => 'phoneNumber', 'required' => true));
        ?>
                </td>
                <td></td>
            </tr> 

        </tbody>
    </table>
       
    </div>

</body>
<?php
$this->endWidget();

?>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button class="btn" onclick="javascript:addJoinEvent<?php echo $eventId; ?>()"><?php echo '提交' ?></button>
</html>
